package com.yqya.springboot.distributedlock.mysql.constants;

import lombok.Getter;

/**
 * 锁信息常量类
 *
 * @author Kevin
 * @date 2019-08-03
 */
public class LockInfoConstants {

    /**
     * 锁状态的枚举类
     */
    @Getter
    public enum LockStatusEnum {
        NO(0, "未锁"),
        YES(1, "已锁");

        /**
         * 值
         */
        private int value;

        /**
         * 名称
         */
        private String name;

        LockStatusEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static String getName(int value) {
            for (LockStatusEnum e : LockStatusEnum.values()) {
                if (e.value == value) {
                    return e.name;
                }
            }
            return "-";
        }

        public static boolean isExist(int value) {
            for (LockStatusEnum item : LockStatusEnum.values()) {
                if (item.value == value) {
                    return true;
                }
            }
            return false;
        }
    }

    /**
     * 删除标记的枚举类
     */
    @Getter
    public enum FlagEnum {
        NO(0, "未删除"),
        YES(1, "已删除"),
        ALL(-1, "全部");

        /**
         * 值
         */
        private int value;

        /**
         * 名称
         */
        private String name;

        FlagEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static String getName(int value) {
            for (FlagEnum e : FlagEnum.values()) {
                if (e.value == value) {
                    return e.name;
                }
            }
            return "-";
        }

        public static boolean isExist(int value) {
            for (FlagEnum item : FlagEnum.values()) {
                if (item.value == value) {
                    return true;
                }
            }
            return false;
        }
    }

}
